package com.cloudlead.plugin.security;

import com.cloudlead.common.lang.BusinessModule;

/**
 * BusinessModules is a Codegen businsess modules type
 */
public enum BusinessModules implements BusinessModule {

    ApiSecurityModule("安全认证模块", null), Authorization("权限认证", ApiSecurityModule),
    ScUser("用户", ApiSecurityModule), ScUserHasRole("用户对应的角色", ScUser), ScUserHasPrivilege("用户对应的权限", ScUser),
    ScRole("角色", ApiSecurityModule), ScRoleHasPrivilege("角色对应的权限", ScRole),
    ScGroup("组", ApiSecurityModule), ScGroupHasUser("组对应的用户", ScGroup), ScGroupHasRole("组对应的角色", ScGroup), ScGroupHasPrivilege("组对应的权限", ScGroup),
    ScPrivilege("权限", ApiSecurityModule), ScResource("资源", ApiSecurityModule);

    private BusinessModules(String label, BusinessModule parent) {
        this.label = label;
        this.parent = parent;
    }

    private String label;
    private BusinessModule parent;

    public String getName() {
        return this.name();
    }

    public BusinessModule getParent() {
        return parent;
    }

    public String getFullName() {
        return null == this.parent ? this.name() : this.parent.getFullName()
                + "-" + this.getName();
    }

    @Override
    public String getLabel() {
        return label;
    }

    @Override
    public int getOrdinal() {
        return this.ordinal();
    }

}
